-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(node): Extract Sentry-specific node-fetch instrumentation #15231
base: develop
Are you sure you want to change the base?
Conversation
3ab670c
to
4c6e295
Compare
size-limit report 📦
|
f44d6a7
to
668c276
Compare
if (Array.isArray(request.headers)) { | ||
const requestHeaders = request.headers; | ||
Object.entries(addedHeaders) | ||
.filter(([k]) => { | ||
// If the header already exists, we do not want to set it again | ||
return !requestHeaders.includes(k); | ||
}) | ||
.forEach(keyValuePair => requestHeaders.push(...keyValuePair)); | ||
} else { | ||
const requestHeaders = request.headers; | ||
request.headers += Object.entries(addedHeaders) | ||
.filter(([k]) => { | ||
// If the header already exists, we do not want to set it again | ||
return !requestHeaders.includes(`${k}:`); | ||
}) | ||
.map(([k, v]) => `${k}: ${v}\r\n`) | ||
.join(''); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m: same concern about the baggage
header as in #15233 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I'll pull this in from the other PR after merging that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated it!
packages/node/src/integrations/node-fetch/SentryNodeFetchInstrumentation.ts
Outdated
Show resolved
Hide resolved
Related to #15231, I noticed that we today would not propagate traces in outgoing http requests if: 1. The user configures `httpIntegration({ spans: false })` 2. ..._or_ the user has a custom OTEL setup 3. _and_ the user does not add their own `HttpInstrumentation` Admittedly and edge case. More importantly, though, by actually adding distributed tracing information here, we are unblocked from potentially stopping to ship the http-instrumentation to users that do not need spans (and/or have a custom otel setup). --------- Co-authored-by: Lukas Stracke <[email protected]>
To allow users to opt-out of using the otel instrumentation.
653a5d8
to
07e8184
Compare
This PR basically mirrors what we did here: #13763
to ensure that the UndiciInstrumentation from fetch can be safely removed.
With this change, if
spans: false
is configured and/orskipOpenTelemetrySetup: true
, no core otel instrumentations will be added anymore at all. This should also make it easier when in a follow up step we make this completely optional, allowing us to drop all instrumentation dependencies for these cases.While doing this I noticed that we should probably also adjust our custom http instrumentation to inject sentry-trace as well, to fully decouple this. I'll check this out separately...
Closes #15212
Possible extension in the future: Also capture fetch request bodies. (We already do not do this today, but may add this at some point...)